<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>打车费用</title>
</head>

<body>
  <script>
    // 3 公里 13 每多一公里 5
    // 堵车 + 10块

    var car = (function () {
      var start = 3;
      var totle = 0;

      return {
        price: function (num) {
          if (num <= start) {
            return totle = 13;
          } else {
            return totle = 13 + (num - start) * 5;
          }
        },
        du: function (flag) {
          return flag ? totle + 10 : totle;
        }
      }
    })();
    console.log(car.price(5)); // 23
    console.log(car.du(true));  // 33

    console.log(car.price(2)); // 13
    console.log(car.du(false));  // 13
  </script>
</body>

</html>